<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<#include "../../base/_meta.html"> 
<@head>
<script type="text/javascript">
	var eee;
	var dialog = frameElement.dialog;
	$(function() {
		$.metadata.setType("attr", "validate");
		var v = $("#form_edit").validate(
				{					//调试状态，不会提交数据的
					debug : true
				});
		$("#form_edit").ligerForm();
	});
	// Save
	function doSave(){
		 var form = liger.get('form_edit');
         if (!form.valid()) {
        	 return;
         }
		$.ajax({
			url:"/auth/user/save",
			data:$("#form_edit").serialize(),
			success:function(msg){
	        	if(msg == "1"){
	        		parent.window.doSearch();// Rfresh grid of users
	        		$.ligerDialog.confirm('保存成功，继续添加或修改数据？', 
	        				function (yes) {
	        				if(yes){
	        					if($("#screen").val()=="A"){
	        						$("#loginaccount").val("");
	        					}
	        				}else{
	        					dialog.close();
	        				}
	        			});
	        		
	        	}else{
	        		$.ligerDialog.error(msg);  
	        	}
	    	}
		});	
	}
</script>
<style type="text/css">
 body{ font-size:12px;}
 .l-table-edit {}
 .l-table-edit-td{ padding:4px;}
 .l-button-submit,.l-button-test{width:60px; float:center; margin-left:10px; padding-bottom:2px;}
 .l-verify-tip{ left:230px; top:120px;}
</style>
</@head>
<body style="overflow-x: hidden; padding: 2px;">
<form id="form_edit" class="liger-form" data-validate="{}">
	<input type="hidden" name="screen" id="screen" value="${(screen)!}"/>
	<table cellpadding="0" cellspacing="0" class="l-table-edit" >
		<tr>
			<td align="right" class="l-table-edit-td">账号:</td>
			<td align="left" class="l-table-edit-td" style="width: 160px">
			<#if screen == "E">
			<input
				name="loginaccount" type="text" id="loginaccount" ltype="text" readonly="readonly"
				value="${(user.loginaccount)!}"
				validate="{required:true,minlength:3,maxlength:50,remote:'/auth/user/samecount?screen=${screen}'}"/>
			</#if>
			<#if screen == "A">
			<input
				name="loginaccount" type="text" id="loginaccount" ltype="text" 
				value="${(user.loginaccount)!}"
				validate="{required:true,minlength:3,maxlength:50,remote:'/auth/user/samecount?screen=${screen}'}"/>
			</#if>	
			</td>
			<td align="left"></td>
		</tr>
		<tr>
			<td align="right" class="l-table-edit-td">密码:</td>
			<td align="left" class="l-table-edit-td" style="width: 160px"><input
				name="password" type="password" id="password" ltype="password"
				validate="{required:true,minlength:3,maxlength:50}" value="${(user.password)!}"/>
			</td>
			<td align="left"></td>
		</tr>
		<tr>
			<td align="right" class="l-table-edit-td">姓名:</td>
			<td align="left" class="l-table-edit-td" style="width: 160px"><input
				name="displayname" type="text" id="displayname" ltype="text"
				validate="{required:true,minlength:2,maxlength:20}" value="${(user.displayname)!}"/>
			</td>
			<td align="left"></td>
		</tr>
		<tr>
            <td align="right" class="l-table-edit-td" valign="top">性别:</td>
            <input type="hidden" id="h_sex" value="${(user.sex)!}"/>
            <td align="left" class="l-table-edit-td" style="width:160px">
				<input id="sex_0" type="radio" name="sex" value="0"/>
                	<label for="sex_0">女士</label> 
                <input id="sex_1" type="radio" name="sex" value="1"/>
                	<label for="sex_1">先生</label>
            </td><td align="left"></td>
        </tr>
        <tr>
           <td align="right" class="l-table-edit-td">备注描述:</td>
           <td align="left" class="l-table-edit-td" colspan="2" > 
           <textarea name="remark" id="remark" cols="40" rows="7" 
           			class="l-textarea"  style="width:400px">${(user.remark)!}</textarea>
           </td> <td align="left"></td>
       </tr>
       <tr>
       <td align="center" class="l-table-edit-td" colspan="4">
			<input type="button" value="保存" class="l-button l-button-test" onclick="doSave();"/>
	   </td>
       </tr>
	</table>
</form>
<script type="text/javascript">
// if has radio,select,checkbox,put here for init
f_initForm();
function f_initForm(){
	var value=$("#h_sex").val();
	if(value == "" || value=="1"){
		$("#sex_1").attr("checked","checked");
	}else{
		$("#sex_0").attr("checked","checked");
	}
}
</script>
</body>
</html>